﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using BVCommon.Entities;
using System.Collections.ObjectModel;
using BVClient.CustomerServiceReference;
using BVClient.ProductServiceReference;
using BVClient.OrderServiceReference;
using ServiceEntities;
using Microsoft.Windows.Controls;
using System.Windows.Threading;
using Formatting;

namespace BVClient
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();

            DispatcherTimer timer = new DispatcherTimer();

            DateTime nowTime = DateTime.Now;


            timer.Interval = TimeSpan.FromMilliseconds(1000);
            timer.Tick += timer_Tick;
            timer.IsEnabled = true;
            timer.Start();
            textBlock1.Text = CurrentTime;
        }

        void timer_Tick(object sender, EventArgs e)
        {
            DateTime nowTime = DateTime.Now;

            CurrentTime =  String.Format("{0} : {1} : {2}", 
                convertToDoubleChar(nowTime.Hour), 
                convertToDoubleChar(nowTime.Minute), 
                convertToDoubleChar(nowTime.Second));
            textBlock1.Text = CurrentTime;
        }

        private static string convertToDoubleChar(int value)
        {
            //if (value>=0 && value<10)
            //{
            //    return "0"+value;
            //}
            //return value.ToString();
            return (value >= 0 && value < 10) ? ("0" + value) : value.ToString();
        }

        public string CurrentTime
        {
            get; set;
        }
    }           
}
